<template>
    <div>
        <Row>
            <i-col span="8">
                <h5 class="mb-4">返回数据的结构说明</h5>
            </i-col>
            <i-col span="14">
                <h5 class="mb-4">真实数据案例</h5>
            </i-col>
        </Row>

        <Row>
            <i-col span="8">
                <v-jstree :data='treeData' :class="{ 'tree-rtl': isRTL }" allow-batch />
            </i-col>
            <i-col span="14">
                <div class="result">
                    <tree-view :data="realData" :options="{maxDepth: 3}"></tree-view>
                </div>
            </i-col>
        </Row>
    </div>
</template>

<style src="@/vendor/libs/vue-data-tables/vue-data-tables.scss" lang="scss"></style>
<style src="@/vendor/libs/sweet-modal-vue/sweet-modal-vue.scss" lang="scss"></style>
<style src="@/vendor/libs/vue-jstree/vue-jstree.scss" lang="scss"></style>
<style scoped>
.result {
    width: auto;
    height: 100%;
    border: 2px dashed gray;
    min-height: 480px;
    background-color: cornsilk;
    padding: 10px;
}
</style>


<script>
import VJstree from "vue-jstree";

export default {
    name: "OriginResult",
    components: {
        VJstree
    },
    props: ["parentOid"],
    data: () => ({
        treeData: [],
        realData: []
    }),
    created() {
        // console.log('Result create',this.prentOid);
        console.log("Result crate", this.parentOid);
        // this.prentOid = this.$emit('getOid').prentOid;
        // this.loadApiRelation(this.prentOid);
    },
    mounted() {
        // console.log('Result mounted',this.prentOid);
        console.log("Result mounted", this.parentOid);
        // this.prentOid = this.$emit('getOid').prentOid;
        this.loadApiRelation(this.parentOid);
        this.loadInterfaceData();
    },
    methods: {
        // 加载指定oid的数据源下探列表
        loadApiRelation(parentOid) {
            console.log("loadApiRelation", parentOid);
            let self = this;
            let url =
                "/app/v1/apis/" +
                parentOid +
                "/resultDict";
            self.$http.get(url+"?pageSize="+1000).then(res => {
                self.treeData = res.data.data;
            });
        },
        loadInterfaceData(parentOid) {
            let self = this;
            let url = "/app/v1/apis/2/result";
            let params = {
                dtype: "json",
                exactlyMatch: "true",
                keyWord: "深圳市一体医疗科技有限公司",
                pageIndex: 1,
                pageSize: 10,
                province: ""
            };
            self.$http.post(url, params).then(res => {
                self.realData = res.data.data;
            });
        }
    }
};
</script>
